//
//  HHBaseTableListCell.m
//  developKit
//
//  Created by Hayder on 2022/12/17.
//

#import "HHBaseTableListCell.h"

@implementation HHBaseTableListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.blankView];
        [self.blankView addSubview:self.lineView];
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat width = self.contentView.width;
    CGFloat height = self.contentView.height;
    self.blankView.frame = CGRectMake(self.blankMarginX, self.blankMarginY, width - 2*self.blankMarginX, height - 2*self.blankMarginY);
    self.lineView.frame = CGRectMake(self.margin, self.blankView.height - 1, self.blankView.width - 2*self.margin, 1);
}

- (UIView *)blankView
{
    if(!_blankView)
    {
        _blankView = [[UIView alloc] init];
        _blankView.backgroundColor = UIColor.whiteColor;
    }
    return _blankView;
}

- (UIView *)lineView
{
    if(!_lineView)
    {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = kGray_240;
    }
    return _lineView;
}

- (void)setConfigWithItem:(HHBaseListItem *)item
{
    self.margin = item.margin;
    self.blankMarginX = item.blankMarginX;
    self.blankMarginY = item.blankMarginY;
    self.isShowLine = item.isShowLine;
    self.titleDefaultWidth = item.titleDefaultWidth;
}

@end
